﻿<UserControl x:Class="Kokomo.PeInspector.Reflection.NamespaceTypesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:r="clr-namespace:Kokomo.PeInspector.Reflection"
			 xmlns:pe="clr-namespace:Kokomo.PeInspector"
			 xmlns:kui="xaml://kokomo/ui"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
	<pe:SearchView>
		<DockPanel>
			<Expander Header="Options" DockPanel.Dock="Bottom">
				<StackPanel>
					<CheckBox IsChecked="{Binding GroupsTypesByKind, Mode=TwoWay}" Content="Group types by kind"/>
				</StackPanel>
			</Expander>

			<ListView
				ItemsSource="{Binding Results}"
				TextSearch.TextPath="MemberName"
				kui:ListViewHelper.IsSortingEnabled="True"
				kui:ListViewHelper.ItemActivatedCommand="{Binding NavigateToCommand}"
				>
				<ListView.ItemContainerStyle>
					<Style>
						<Setter Property="kui:ListViewHelper.ItemParameter" Value="{Binding Member}"/>
					</Style>
				</ListView.ItemContainerStyle>
				<ListView.View>
					<GridView>
						<GridViewColumn Header="Name">
							<GridViewColumn.CellTemplate>
								<DataTemplate DataType="{x:Type r:TypeMemberItem}">
									<ContentPresenter Content="{Binding ViewInfo}"/>
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
					</GridView>
				</ListView.View>
				<ListView.GroupStyle>
					<GroupStyle>
						<GroupStyle.ContainerStyle>
							<Style TargetType="{x:Type GroupItem}">
								<Setter Property='Template'>
									<Setter.Value>
										<ControlTemplate TargetType="{x:Type GroupItem}">
											<Expander IsExpanded="True">
												<Expander.Template>
													<ControlTemplate TargetType="{x:Type Expander}">
														<Grid>
															<Grid.RowDefinitions>
																<RowDefinition Height="Auto"/>
																<RowDefinition Height="Auto"/>
															</Grid.RowDefinitions>

															<Grid>
																<Grid.ColumnDefinitions>
																	<ColumnDefinition Width="Auto"/>
																	<ColumnDefinition Width="*"/>
																</Grid.ColumnDefinitions>

																<ToggleButton
																		VerticalAlignment="Center"
																		IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
																		>
																	<ToggleButton.Template>
																		<ControlTemplate TargetType="{x:Type ToggleButton}">
																			<Path
																					x:Name="Arrow"
																					Width="5"
																					Height="9"
																					Stroke="Black"
																					Fill="Black"
																					Margin="6"
																					Data="M 0,0 L 0,8 L 4,4 Z"
																					/>
																			<ControlTemplate.Triggers>
																				<Trigger Property="IsChecked" Value="True">
																					<Setter TargetName="Arrow" Property="Data" Value="M 0,4 L 4,0 L 4,4 Z"/>
																				</Trigger>
																			</ControlTemplate.Triggers>
																		</ControlTemplate>
																	</ToggleButton.Template>
																</ToggleButton>

																<ContentPresenter
																		Grid.Column="1"
																		ContentSource="Header"
																		/>
															</Grid>

															<ContentPresenter
																	Grid.Row="1"
																	x:Name="ContentRow"
																	>
															</ContentPresenter>
														</Grid>
														<ControlTemplate.Triggers>
															<Trigger Property="IsExpanded" Value="False">
																<Setter TargetName="ContentRow" Property="Visibility" Value="Collapsed"/>
															</Trigger>
														</ControlTemplate.Triggers>
													</ControlTemplate>
												</Expander.Template>

												<Expander.Header>
													<TextBlock FontWeight="Bold">
														<TextBlock.Text>
															<Binding Path="Name" StringFormat="{}{0} members"/>
														</TextBlock.Text>
													</TextBlock>
												</Expander.Header>
												<Expander.Content>
													<ItemsPresenter Margin="12 0 0 0"/>
												</Expander.Content>
											</Expander>
										</ControlTemplate>
									</Setter.Value>
								</Setter>
							</Style>
						</GroupStyle.ContainerStyle>
					</GroupStyle>
				</ListView.GroupStyle>
			</ListView>
		</DockPanel>
	</pe:SearchView>
</UserControl>
